package es.cazadoresmadridejos.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.springframework.web.multipart.commons.CommonsMultipartFile;

@Entity(name="Adviced")
@Table(name="aviso")
public class Adviced extends BaseEntity{

	private static final long serialVersionUID = -4069742559928978776L;

	private Reason reason;
	private String imageUrl;
	private String text;
	private Boolean active;
	private Date date;
	private String title;
	
	//transient
	private CommonsMultipartFile  file;
	
	@ManyToOne(optional=false)
	@JoinColumn(name="temporada")
	public Reason getReason() {
		return reason;
	}
	public void setReason(Reason reason) {
		this.reason = reason;
	}
	@Column(name="imagen")
	public String getImageUrl() {
		return imageUrl;
	}
	public void setImageUrl(String imageUrl) {
		this.imageUrl = imageUrl;
	}
	
	@Lob
	@Column(name="texto")
	public String getText() {
		return text;
	}
	public void setText(String text) {
		this.text = text;
	}
	@Column(name="activo")
	public Boolean getActive() {
		return active;
	}
	public void setActive(Boolean active) {
		this.active = active;
	}
	@Column(name="fecha")
	public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}
	@Column(name="titulo")
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	
	@Transient
	public CommonsMultipartFile getFile() {
		return file;
	}
	public void setFile(CommonsMultipartFile file) {
		this.file = file;
		this.imageUrl = file.getOriginalFilename();
	}
	
	
}
